﻿Imports FuncClasses

Public Class CustomPlugIn
    Implements Biller.IPlugIn2

    Private t As DHLTab
    Private parent As Biller.Window1
    Private _user As User

    Public Sub New(ByRef _parent As Biller.Window1)
        parent = _parent
        _parent.UpdateChecker.AddFile(New UpdateFileInfo("PacketTracking.addin", "Erweiterung zur Sendungsverfolgung", Version))
        _parent.AddNewLicense("HTML Agility Pack", "Microsoft Public License (Ms-PL)", My.Resources.mspl)
    End Sub

    Public Sub Disable() Implements Biller.IPlugIn2.Disable
        Try
            parent.MainGrid.Children.Remove(t.t1)

            'parent.RibbonControl.Tabs.Remove(t.dhl)
            t = Nothing
        Catch ex As Exception : End Try
    End Sub

    Public Sub Initialize() Implements Biller.IPlugIn2.Initialize
        t = New DHLTab(parent, Nothing)
        t.Grid1.Children.Clear()
        t.TabControl.Items.Clear()

        parent.AddNewRibbonTab(t.dhl, t.t1)
    End Sub

    Public ReadOnly Property Name As String Implements Biller.IPlugIn2.Name
        Get
            Return "Paketverfolgung"
        End Get
    End Property

    Public ReadOnly Property Author As String Implements Biller.IPlugIn2.Author
        Get
            Return "Igor Lückel"
        End Get
    End Property

    Public ReadOnly Property Version As Decimal Implements Biller.IPlugIn2.Version
        Get
            Return 1.1
        End Get
    End Property

    'Public Property MainWindow As Biller.Window1 Implements Biller.IPlugIn2.MainWindow
    '    Get
    '        Return parent
    '    End Get
    '    Set(value As Biller.Window1)
    '        parent = value
    '    End Set
    'End Property

    Public ReadOnly Property IsEnabled As Boolean Implements Biller.IPlugIn2.IsEnabled
        Get
            If t Is Nothing Then
                Return False
            Else : Return True
            End If
        End Get
    End Property

    Public Sub NewOrderControl(ByRef control As Biller.AuftragControl) Implements Biller.IPlugIn2.NewOrderControl
        If IsEnabled Then
            Dim tabitem As New TabItemTemplate
            tabitem.Content = New AuftragsTab(control.CompleteAuftrag, control, parent.Database)
            control.TabControl.Items.Add(tabitem)
        End If
    End Sub

    Private Shared dhlbusiness As DHLOnlineLogin
    Public Shared Property DHL_BusinessManager As DHLOnlineLogin
        Get
            Return dhlbusiness
        End Get
        Set(value As DHLOnlineLogin)
            dhlbusiness = value
        End Set
    End Property

    Public Property Database As IDatabase Implements Biller.IPlugIn2.Database

    Public ReadOnly Property GUID As Guid Implements Biller.IPlugIn2.GUID
        Get
            Return New Guid("a3b7d618-2579-4cb6-bb69-0bb5f1b21d2b")
        End Get
    End Property

    Public Sub SetUser(user As User) Implements Biller.IPlugIn2.SetUser
        _user = user
    End Sub

    Public ReadOnly Property UserRequest As nHibernate.Models.UserPreviewModel Implements Biller.IPlugIn2.UserRequest
        Get
            Return New nHibernate.Models.UserPreviewModel()
        End Get
    End Property
End Class
